import 'package:flutter/material.dart';
import 'package:flutter_bilibili/core/extension/int_extension.dart';
import 'package:flutter_bilibili/ui/pages/live/initialize_live.dart';
import 'package:flutter_bilibili/ui/pages/live/live_room_recommend.dart';
import 'package:flutter_bilibili/ui/shared/image_assets.dart';
import '../../shared/app_theme.dart';
import 'live_room_wzry.dart';

class HYLiveContent extends StatelessWidget {
  const HYLiveContent({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: liveTabTitle.length,
      child: Scaffold(
        appBar: AppBar(
          toolbarHeight: 40.px,

          /// 高度
          elevation: 0,

          /// 阴影
          title: buildTabBar(),
        ),
        body: buildLiveTabBarView(),
      ),
    );
  }

  Widget buildTabBar() {
    return Container(
      padding: EdgeInsets.only(left: 8.px, right: 16.px),
      child: Stack(
        children: [
          Positioned(
            right: 0,
            top: 0,
            bottom: 0,
            child: Image.asset(
              ImageAssets.liveMoreCustomPNG,
              width: 17.px,
              height: 17.px,
            ),
          ),
          Container(
            margin: EdgeInsets.only(right: 30.px),
            child: TabBar(
              tabs: liveTabTitle.map((e) => Tab(text: e)).toList(),
              isScrollable: true,
              labelStyle: const TextStyle(
                  fontWeight: FontWeight.bold,
                  fontSize: HYAppTheme.xxSmallFontSize),
              unselectedLabelStyle: const TextStyle(
                  fontWeight: FontWeight.normal,
                  fontSize: HYAppTheme.xxSmallFontSize),
              unselectedLabelColor: Color.fromRGBO(95, 95, 95, 1),
              labelColor: Colors.black,
            ),
          ),
        ],
      ),
    );
  }

  Widget buildLiveTabBarView() {
    return TabBarView(
        children: liveTabTitle.map((e) {
          if (e == '推荐') {
        return HYLiveRecommendScreen();
      } else if (e == '颜值') {
        return HYLiveRecommendScreen();
      } else if (e == '英雄联盟') {
        return HYLiveRecommendScreen();
      } else if (e == '王者荣耀') {
        return HYLiveWangZheRongYaoScreen();
      } else if (e == '虚拟主播') {
        return HYLiveRecommendScreen();
      } else if (e == 'LOL手游') {
        return HYLiveRecommendScreen();
      } else if (e == '电台') {
        return HYLiveRecommendScreen();
      } else if (e == '单机游戏') {
        return HYLiveRecommendScreen();
      } else if (e == '娱乐') {
        return HYLiveRecommendScreen();
      } else {
        return HYLiveRecommendScreen();
      }
    }).toList());
  }
}
